<html>
<head><meta charset="utf-8"><title>borrowck · t-compiler/performance · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/index.html">t-compiler/performance</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/borrowck.html">borrowck</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="223676251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/borrowck/near/223676251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/borrowck.html#223676251">(Jan 22 2021 at 17:59)</a>:</h4>
<p>Why does MIR_effect_checking (more precisely, mir_drops_elaborated_and_const_checked) run borrowck? There is a comment (This also runs mir borrowck <em>before</em> doing so in order to ensure that borrowck can be run and doesn't end up missing the source MIR due to stealing happening.) but the pass runs <em>after</em> borrowck so I believe this just re-runs the check?</p>



<a name="223677301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/borrowck/near/223677301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/borrowck.html#223677301">(Jan 22 2021 at 18:07)</a>:</h4>
<p>I guess the question is whether borrowck runs twice in some cases, or I don't understand what ensure does? <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="223681253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/borrowck/near/223681253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tyson Nottingham <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/borrowck.html#223681253">(Jan 22 2021 at 18:37)</a>:</h4>
<p>The borrowck result for the particular def_id should be cached by the first query, so the second borrowck for that def_id shouldn't actually run.</p>
<p>The <code>ensure()</code> just means to ensure that the query result is in the cache (i.e. if the query hasn't run, run it and cache result, otherwise do nothing), and that the client isn't interested in the actual return value, so we can avoid the work of extracting it from the cache.</p>



<a name="223681385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/borrowck/near/223681385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tyson Nottingham <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/borrowck.html#223681385">(Jan 22 2021 at 18:38)</a>:</h4>
<p>I don't know the details of <code>mir_drops_elaborated_and_const_checked</code> and <code>borrowck</code> specifically, but I assume the former runs the latter because it is called by other clients who <em>don't</em> run <code>borrowck</code> before calling it.</p>



<a name="223681629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/borrowck/near/223681629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/borrowck.html#223681629">(Jan 22 2021 at 18:40)</a>:</h4>
<p>Thanks</p>



<a name="223681933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/borrowck/near/223681933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/borrowck.html#223681933">(Jan 22 2021 at 18:43)</a>:</h4>
<p>I guess what mislead me somewhat is the comment above ensure: "Returns a transparent wrapper for <code>TyCtxt</code>, which ensures queries are executed instead of just returning their results." - I guess I should look for the eval_always flag on the particular query, right?</p>



<a name="223685083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/borrowck/near/223685083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tyson Nottingham <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/borrowck.html#223685083">(Jan 22 2021 at 19:11)</a>:</h4>
<p>Yeah, that comment could use some tuning. :)</p>
<p><code>eval_always</code> query results are cached in memory too. So it wouldn't run twice if it were <code>eval_always</code>, either. "Always" doesn't mean <em>always</em>. :) It means the first time we encounter this query during incremental compilation.</p>



<a name="223685719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/borrowck/near/223685719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tyson Nottingham <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/borrowck.html#223685719">(Jan 22 2021 at 19:17)</a>:</h4>
<p>The name should probably be changed, really</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>